package cmj.cloudmusic.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.example.musicmodule.entity.Music;
import com.example.musicmodule.util.GetLocalMusicUtil;

import java.util.ArrayList;
import java.util.List;

import cmj.cloudmusic.R;
import cmj.cloudmusic.adapter.Music_ListView_Adapter;

/**
 * Created by 王虎 on 2016/12/19.
 */

public class MyLocalSongListFragment extends Fragment {

    Context context;
    List<Music> list;
    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.context=context;
    }

    ListView listView;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        listView= (ListView) inflater.inflate(R.layout.mylocalsonglistview,null);
        list=new ArrayList<>();

        list.addAll(GetLocalMusicUtil.getMusicData(context));

        Music_ListView_Adapter adapter=new Music_ListView_Adapter(context,list);
        listView.setAdapter(adapter);
        return listView;
    }
}
